<!--
 * @Description:循环四要素
 * @Author: Sun
 * @Date: 2019-07-01 20:05:50
 * @LastEditors: Sun
 * @LastEditTime: 2019-07-01 22:42:14
 -->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>循环四要素</title>
  <script>
    window.onload = function () {
      let dv = document.getElementById("km")
      //获取标签的个数
      let lis = document.getElementsByTagName("li")
      console.log("lm",lis.length)
     
      // var i=0;
      // while(i<3){
      //   alert(i)
      //   i++
      // }

      for (let index = 0; index <lis.length; index++) {
      const element = lis[index];
      element.style.background="green";
   }
       
      dv.onclick = function () {
        dv['value'] = '提取行间事件window.onload'
      }
      

    }
  </script>
</head>

<body>
  <input id="km" type="button" value="皮肤1">
  <ul >
    <li>循环四要素</li>
    <li>初始化 ‘i=0’</li>
    <li>结束条件 "i<5" </li>
    <li>'alert(i)循环语句'</li>
    <li>‘自增’</li>
  </ul>
  <style>
    .d1 {
      background: #000;
      color: #fff;
    }

    .d2 {
      background: yellow;
      color: #000;
    }
  </style>


</body>

</html>